package com.zzl.bonds.ticket.constant;

/**
 * @author : spp
 * @date : 2021/11/13 16:13
 */
public enum NodeStatusEnum {

    /**
     * 1 未开启 2 待审批 3 审批中 4 审批完成 5 驳回
     * 未开启
     */
    NO_OPEN(1, "未开启"),


    /**
     * 审批中
     */
    APPROVAL_ING(2, "审批中"),

    /**
     * 审批完成
     */
    APPROVAL_FINISH(3, "审批完成"),

    /**
     * 驳回
     */
    REJECT(4, "驳回"),

    /**
     * 撤销申请
     */
    CANCEL(5, "撤销申请");

    private Integer code;
    private String value;


    NodeStatusEnum(Integer code, String value) {
        this.code = code;
        this.value = value;
    }

    public static String getValue(Integer code) {
        NodeStatusEnum anEnum = getEnum(code);
        if(anEnum != null){
            return anEnum.value;
        }
        return "";
    }

    public static NodeStatusEnum getEnum(Integer code) {
        if(null == code){
            return null;
        }
        for (NodeStatusEnum statusEnum : NodeStatusEnum.values()) {
            if (statusEnum.code.equals(code)) {
                return statusEnum;
            }
        }
        return null;
    }

    public static Integer nodeStatusAdapter(Integer status) {
        if (status.equals(NodeStatusEnum.APPROVAL_FINISH.getCode())) {
            // 通过
            return 3;
        }
        if (status.equals(NodeStatusEnum.APPROVAL_ING.getCode())) {
            // 审批中
            return 1;
        }
        if (status.equals(NodeStatusEnum.REJECT.getCode())) {
            // 拒绝 不通过
            return 2;
        }
        return null;
    }


    public Integer getCode() {
        return code;
    }

    public String getValue() {
        return value;
    }
}
